<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<%@ page import="jpa.*"%>
<%@ page import="pkg.*"%>
<%@ page import="java.util.*"%>

<%
	IStatelessBean statelessBean = (IStatelessBean) session.getAttribute("statelessBean");
	IStatefulBean statefulBean = (IStatefulBean) session.getAttribute("statefulBean");

	Page currentPage = statefulBean.getCurrentPage();
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title><%=currentPage.getPgTitle()%></title>
</head>
<body>
	<h1><%=currentPage.getPgTitle()%></h1>
	<%
		if (statelessBean.isMenuPage(currentPage))
		{
	%><ul>
		<%
			for (Link l : statelessBean.getMenuLinks(currentPage))
				{
		%><li><a
			href="Controller?do=test&amp;id=<%=l.getPage1().getPgId()%>"><%=l.getPage1().getPgTitle()%></a>
		</li>
		<%
			}
		%>
	</ul>
	<%
		} 
		else
		{
			if (statelessBean.isAppletPage(currentPage))
			{
		%>
			<applet <%=currentPage.getPgContent()%>>
				Your browser does not support the <code>applet</code> tag.
			</applet> 
		<script type="text/javascript" src="<%=currentPage.getPgContent()%>"></script>
		<%
			}
		
			else if (statelessBean.isImagePage(currentPage))
			{
				%>
				<img src = "<%=currentPage.getPgContent()%>" />
				<%
			}
			else if (statelessBean.isVideoPage(currentPage))
			{
				%>
				<iframe class = "video" width="560" height="315" src="<%=currentPage.getPgContent()%>" frameborder="0" allowfullscreen></iframe>
				<%
			}
			else if (statelessBean.isTextPage(currentPage))
			{
				%><%=currentPage.getPgContent()%><%
			}

	%><p>Page content:</p><%=currentPage.getPgContent()%>
	<%
		Link next = statelessBean.getNextLink(currentPage);
			if (next != null)
			{
	%><p>
		Next: <a
			href="Controller?do=test&amp;id=<%=next.getPage1().getPgId()%>"><%=next.getPage1().getPgTitle()%></a>
	</p>
	<%
		}
			Link previous = statelessBean.getPreviousLink(currentPage);
			if (previous != null)
			{
	%><p>
		Previous: <a
			href="Controller?do=test&amp;id=<%=previous.getPage2().getPgId()%>"><%=previous.getPage2().getPgTitle()%></a>
	</p>
	<%
		}
			Link up = statelessBean.getUpLink(currentPage);
			if (up != null)
			{
	%><p>
		Up: <a href="Controller?do=test&amp;id=<%=up.getPage2().getPgId()%>"><%=up.getPage2().getPgTitle()%></a>
	</p>
	<%
		}
			Link down = statelessBean.getDownLink(currentPage);
			if (down != null)
			{
	%><p>
		Down: <a
			href="Controller?do=test&amp;id=<%=down.getPage1().getPgId()%>"><%=down.getPage1().getPgTitle()%></a>
	</p>
	<%
		}
			List<Link> other = statelessBean.getOtherLinks(currentPage);
			if (other.size() > 0)
			{
	%><p>See also:</p>
	<%
		for (Link l : other)
				{
	%><p>
		<a href="Controller?do=test&amp;id=<%=l.getPage1().getPgId()%>"><%=l.getPage1().getPgTitle()%></a>
	</p>
	<%
		}
			}
		}
	%>
</body>
</html>